package tangjl.timer.task;

import org.apache.log4j.Logger;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class RunPoint {
	private static Logger logger = Logger.getLogger(RunPoint.class);

	public static void main(String[] args) {
		String settingPath = args != null && args.length > 0 ? args[0] : null;
		if (logger.isInfoEnabled()) logger.info("启动Spring");
		if (null == settingPath || settingPath.isEmpty()) {
			// XML配置模式
			// 该模式使用Quartz,所以需要本Demo中POM中的所有应用包
			new ClassPathXmlApplicationContext("spring-application-quartz-xml.xml");
			// 注解配置模式
			// 该模式是Spring自带的task,而不是Quartz,可以将它看成一个轻量级的Quartz,所以只需要引入Spring基础包就行了
			// <groupId>org.springframework</groupId><artifactId>spring-context</artifactId>
			new ClassPathXmlApplicationContext("spring-application-task-annotation.xml");
		} else {
			if (logger.isInfoEnabled()) logger.info("配置文件:" + settingPath);
			new FileSystemXmlApplicationContext(settingPath);
		}
		if (logger.isInfoEnabled()) logger.info("启动完成");
	}
}
